package com.tianji.learning.contoller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.ReplyDTO;
import com.tianji.learning.domain.query.ReplyPageQuery;
import com.tianji.learning.domain.vo.ReplyVO;
import com.tianji.learning.service.InteractionReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author : Cammy.Wu
 * Description : 
 */

@RestController
@RequestMapping("/replies")
@RequiredArgsConstructor
@Api(tags = "互动问答相关接口 ")
public class InteractionReplyController {
    // 回答：回复内容、是否匿名、问题id
    // 评论：回复内容、是否匿名、问题id、回答id、目标评论id、目标用户id

    private InteractionReplyService replyService;

    /**
     * 新增回答或评论
     * @param replyDTO
     */
    @ApiOperation("新增回答或评论")
    @PostMapping
    public void saveReply(@RequestBody ReplyDTO replyDTO) {
        replyService.saveReply(replyDTO);
    }

    /**
     * 分页查询回答或评论
     * @param replyPageQuery
     * @return
     */
    @ApiOperation("分页查询回答或评论")
    @GetMapping("/page")
    public PageDTO<ReplyVO> queryReplyPage(@RequestBody ReplyPageQuery replyPageQuery) {
        return replyService.queryReplyPage(replyPageQuery, false);
    }
}
